package com.own.component.util.excel.util.write.style.css.impl;

import com.own.component.util.excel.util.write.style.css.ExcelCssAttribute;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import org.apache.poi.ss.usermodel.BorderStyle;

/**
 * Border
 *
 * @author chenxueli
 * @date 2022-06-15 03:14:15
 */
public class Border implements ExcelCssAttribute {

    private final AbstractBorder bottom;
    private final AbstractBorder left;
    private final AbstractBorder right;
    private final AbstractBorder top;

    public Border(Style style, Color color) {
        this.bottom = new BorderBottom(style, color);
        this.left = new BorderLeft(style, color);
        this.right = new BorderRight(style, color);
        this.top = new BorderTop(style, color);
    }

    /**
     * 渲染成style
     *
     * @param style 样式信息
     */
    @Override
    public void build(com.own.component.util.excel.util.write.model.Style style) {
        bottom.build(style);
        left.build(style);
        right.build(style);
        top.build(style);
    }

    @Getter
    @AllArgsConstructor
    @SuppressWarnings("all")
    public enum Style {
        NONE(BorderStyle.NONE),
        THIN(BorderStyle.THIN),
        MEDIUM(BorderStyle.MEDIUM),
        DASHED(BorderStyle.DASHED),
        DOTTED(BorderStyle.DOTTED),
        THICK(BorderStyle.THICK),
        DOUBLE(BorderStyle.DOUBLE),
        HAIR(BorderStyle.HAIR),
        MEDIUM_DASHED(BorderStyle.MEDIUM_DASHED),
        DASH_DOT(BorderStyle.DASH_DOT),
        MEDIUM_DASH_DOT(BorderStyle.MEDIUM_DASH_DOT),
        DASH_DOT_DOT(BorderStyle.DASH_DOT_DOT),
        MEDIUM_DASH_DOT_DOT(BorderStyle.MEDIUM_DASH_DOT_DOT),
        SLANTED_DASH_DOT(BorderStyle.SLANTED_DASH_DOT);

        private final BorderStyle value;
    }

    public enum Color {}

    @Data
    public static abstract class AbstractBorder implements ExcelCssAttribute {

        private Style style;
        private Color color;

        public AbstractBorder(Style style, Color color) {
            this.style = style;
            this.color = color;
        }
    }

}
